<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品列表</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
        }
        table {
            width: 800px;
            margin: 20px auto;
            border-collapse: collapse;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        table, th, td {
            border: 1px solid #ddd;
        }
        th, td {
            padding: 10px;
            text-align: center;
        }
        th {
            background-color: #4CAF50;
            color: white;
        }
        tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        a {
            text-decoration: none;
            color: #007BFF;
            margin: 0 5px;
        }
        a:hover {
            color: #0056b3;
        }
        form {
            margin-bottom: 20px;
            text-align: center;
        }
        input[type="hidden"] {
            display: none;
        }
        .button {
            display: inline-block;
            padding: 5px 10px;
            background-color: #007BFF;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        .button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<a href="/product/input" class="button">新增</a>

<!-- 查询的表单 -->
<form action="/product/list" method="post">
    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
</form>

<table cellpadding="0" cellspacing="0" align="center">
    <tr>
        <td>ID</td>
        <td>商品名称</td>
        <td>price</td>
        <td>stock</td>
        <td>url</td>
        <td>描述</td>
    </tr>
    <c:forEach items="${pageResult.data}" var="product">
        <tr>
            <td>${product.id}</td>
            <td>${product.productName}</td>
            <td>${product.price}</td>
            <td>${product.stock}</td>
            <td>${product.url}</td>
            <td>${product.description}</td>
            <td>
                <a href="/product/detail?id=${product.id}" class="button">详情</a>

            </td>
        </tr>
    </c:forEach>

    <tr align="center">
        <td colspan="9">
            <a href="javascript:goPage(1);">首页</a>
            <a href="javascript:goPage(${pageResult.prevPage});">上一页</a>
            <a href="javascript:goPage(${pageResult.nextPage});">下一页</a>
            <a href="javascript:goPage(${pageResult.totalPage});">尾页</a>
            当前:${pageResult.currentPage}/${pageResult.totalPage}
            总条数:${pageResult.totalCount}
        </td>
    </tr>
    <script>
        function goPage(currentPage){
            document.getElementById("currentPage").value=currentPage;
            document.forms[0].submit();
        }
    </script>
</table>
</body>
</html>